

import 'package:basic_common/app_theme.dart';
import 'package:basic_common/common_exports.dart';
import 'package:basic_widgets/button_widget.dart';
import 'package:basic_widgets/input_widget.dart';
import '../../service_detail_controller.dart';


/* 
 * @description: //添加体重数据
 * @author: Jane 
 * @date: 2023-09-20 15:06:01
 */
class AddWeightDialog extends GetView<ServerDetailController> {
  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: ScreenHelper.width(15)),
      child: SimpleDialog(
        title: const Align(
          alignment: Alignment.topCenter,
          child: Text("添加体重"),
        ),
        children: [
          Container(
            width: ScreenHelper.screenWidth,
            padding: EdgeInsets.symmetric(horizontal: ScreenHelper.width(15)),
            child: buildAddItem(
                name: "体重",
                unit: "kg",
                inputController: controller.weightController),
          ),
          Container(
            alignment: Alignment.topCenter,
            padding: EdgeInsets.symmetric(horizontal: ScreenHelper.width(15)),
            child: buildEstimateWidget(),
          ),
          SizedBox(
            height: ScreenHelper.height(15),
          ),
          Container(
            padding: EdgeInsets.symmetric(horizontal: ScreenHelper.width(15)),
            child: Row(
              children: [
                Expanded(
                    child: roundBtn(
                        onTap: () {
                          Get.back();
                        },
                        text: "取消",
                        bgColor: Colors.white,
                        textColor: AppTheme.primyColor,
                        borderColor: AppTheme.primyColor)),
                SizedBox(
                  width: ScreenHelper.width(10),
                ),
                Expanded(
                    child: roundBtn(
                        onTap: () {
                          Get.back();
                          controller.addWeightData(
                              weightValue: controller.weightController.text,
                              evaValue: controller.evaController.text);
                        },
                        text: "添加",
                        bgColor: AppTheme.primyColor,
                        textColor: Colors.white)),
              ],
            ),
          )
        ],
      ),
    );
  }

  /// 评估内容
  Widget buildEstimateWidget() {
    return Container(
      alignment: Alignment.topCenter,
      child: Row(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          SizedBox(
            width: ScreenHelper.width(40),
            child: const Text(
              "评估",
              textAlign: TextAlign.left,
              style: TextStyle(color: AppTheme.dartWeakTextColor),
            ),
          ),
          Expanded(
            child: Container(
              alignment: Alignment.topCenter,
              child: mutileTextField(
                  hintText: "请输入评估内容",
                  textController: controller.evaController,
                  countNum: "",
                  minLines: 2),
            ),
          ),
        ],
      ),
    );
  }

  /// item
  Widget buildAddItem(
      {required String name,
      required String unit,
      required TextEditingController inputController}) {
    return SizedBox(
      height: ScreenHelper.height(60),
      child: Row(
        children: [
          SizedBox(
            width: ScreenHelper.width(60),
            child: Text(
              name,
              textAlign: TextAlign.left,
              style: TextStyle(color: AppTheme.dartWeakTextColor),
            ),
          ),
          Expanded(
              child: inputBox(hintText: '', inputController: inputController)),
          SizedBox(
            width: ScreenHelper.width(6),
          ),
          Text(
            '${unit}',
            style: TextStyle(color: AppTheme.dartWeakTextColor),
          ),
        ],
      ),
    );
  }
}
